package com.example.element.module.jetpack.lifecycles

import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleObserver
import androidx.lifecycle.OnLifecycleEvent
import com.example.common.utils.L

/**
 * 监听生命周期
 */
class MyObserver : LifecycleObserver {

    val TAG = "MyObserver"

    @OnLifecycleEvent(Lifecycle.Event.ON_START)
    fun actStart() {
        L.e(TAG, "actStart")
    }

    @OnLifecycleEvent(Lifecycle.Event.ON_STOP)
    fun actStop() {
        L.e(TAG, "actStop")
    }

    /**
     * 匹配所有生命周期
     */
    @OnLifecycleEvent(Lifecycle.Event.ON_ANY)
    fun actAny() {
        L.e(TAG, "actAny")
    }
}